<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Exception;

class NavSetController extends Controller
{
    //导航列表
    public  function  lists(){
        $nav_lists = Db::table('menu')->orderBy('orders','desc')->paginate(15);


        return view('nav_lists',['nav_lists'=>$nav_lists]);
    }

    public  function nav_edit(Request $request,$id){
        $where[] = ['id','=',$id];
        $nav_edit = Db::table('menu')->where($where)->first();

        return view('nav_edit',['nav_edit'=>$nav_edit,'id'=>$id]);
    }

    public function nav_do(Request $request){
        $input = $request->input();

        $update['orders'] = $input['orders'];
        $update['en_name'] = $input['enName'];
        $update['tc_name'] = $input['tcName'];

        Db::table('menu')->where('id','=',$input['id'])->update($update);

        return response()->json([
            'status' => 1,
            'result' => [],
            'message' => '操作成功！'
        ]);
    }
}
